# Copyright (c) 2019-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
#
import sys

def f_gold ( A , B , m , n ) :
    A.sort ( )
    B.sort ( )
    a = 0
    b = 0
    result = sys.maxsize
    while ( a < m and b < n ) :
        if ( abs ( A [ a ] - B [ b ] ) < result ) :
            result = abs ( A [ a ] - B [ b ] )
        if ( A [ a ] < B [ b ] ) :
            a += 1
        else :
            b += 1
    return result


#TOFILL

if __name__ == '__main__':
    param = [
    ([2, 2, 11, 13, 18, 18, 23, 25, 28, 28, 37, 39, 53, 56, 67, 70, 74, 74, 75, 79, 80, 82, 84, 89, 94, 95, 95, 98, 98],[5, 6, 11, 13, 13, 16, 17, 19, 23, 25, 28, 31, 31, 39, 41, 44, 45, 52, 62, 64, 70, 71, 73, 78, 78, 79, 85, 86, 92],28,14,),
    ([-78, 10, -8, 30, -70, -94, -48, -4, -22, -40, -36, -48, -4, 86, -50, 62, -72, -44, -62, 22, -30, -72, 6, -24, -78, 72, -44, 56, 38, -36, 0, -72, -10, -12, -70, -64, -24],[78, -80, -24, -50, -26, -62, 26, -12, 22, -90, 84, 10, 18, 62, 26, -68, 92, 64, -52, 76, -84, 64, 50, 36, -24, -98, 42, 72, -78, -98, -24, 86, 2, 60, -30, 14, -42],23,33,),
    ([0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],14,16,),
    ([57, 82, 90, 9, 61, 71, 15, 2, 39, 24, 28, 28, 47],[85, 92, 84, 27, 54, 77, 26, 49, 47, 51, 70, 11, 41],7,8,),
    ([-92, -90, -90, -28, -16, -14, -14, -8, 42, 52, 62, 84],[-98, -98, -58, -6, 14, 16, 18, 46, 52, 52, 52, 56],11,6,),
    ([1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 0],[0, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 1],35,33,),
    ([6, 7, 7, 12, 15, 15, 21, 24, 26, 26, 28, 36, 38, 42, 46, 52, 55, 56, 59, 62, 63, 65, 65, 66, 68, 71, 73, 77, 77, 77, 77, 85, 87, 87, 88, 90, 93, 94, 98],[1, 3, 4, 4, 6, 7, 8, 8, 15, 17, 18, 18, 20, 23, 23, 24, 25, 25, 26, 33, 39, 43, 46, 54, 59, 67, 69, 69, 69, 69, 76, 76, 81, 81, 85, 86, 86, 91, 95],30,20,),
    ([-68, 44, 88, -68, 22, 34, -82, 18, -60, 30, 24, 18, 78, 90, -20, -60, 94, 70, 4, -16, -38],[-18, -30, -74, -50, 98, -44, -62, -20, 18, 84, 62, -64, -2, 62, -32, -34, -14, -52, -36, -60, -68],16,12,),
    ([0, 0, 1],[0, 0, 1],2,1,),
    ([14, 7, 9, 71, 37, 20, 85, 62, 70, 67, 26, 47, 61, 99, 2, 90, 70, 46, 53, 16, 56, 7, 15, 81, 85, 94, 73, 40, 35, 58, 21, 98, 45],[99, 72, 29, 55, 88, 1, 88, 19, 7, 80, 79, 18, 28, 41, 48, 49, 67, 27, 24, 94, 86, 14, 45, 84, 37, 71, 92, 98, 16, 64, 67, 44, 29],20,25,)
        ]
    n_success = 0
    for i, parameters_set in enumerate(param):
        if f_filled(*parameters_set) == f_gold(*parameters_set):
            n_success+=1
    print("#Results: %i, %i" % (n_success, len(param)))